<template>
  <div class="bg">
    <!-- 头部 -->
    <Header title="系统管理—维修项目"></Header>

    <!-- 标签页 -->
    <el-tabs type="border-card">
      <!-- 1 -->
      <el-tab-pane label="维修项目类别">
        <!-- 搜索栏 -->
        <section class="search_bar">
          <LButton label="+新增" @click="repairDialog = true"></LButton>
        </section>
        <!-- 表格 -->
        <el-table :data="tableData" style="width: 100%" :default-sort="{prop:'b',order:ascending}" border>
          <el-table-column label="项目类别编码" prop="a" width="200" />
          <el-table-column label="项目类别名称" prop="b" />
          <el-table-column label="备注" prop="c" />
          <el-table-column label="操作" width="140">
            <template #default>
              <el-button type="primary" size="mini" @click="repairDialog1 = true">编辑</el-button>
              <el-button type="danger" size="mini" @click="del">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <!-- 2 -->
      <el-tab-pane label="维修项目">
        <!-- 搜索栏 -->
        <section class="search_bar">
          <LButton label="+新增" @click="repairDialog2 = true"></LButton>
        </section>
        <!-- 表格 -->
        <el-table :data="tableData1" style="width: 100%" :default-sort="{prop:'b',order:ascending}" border>
          <el-table-column label="项目编码" prop="a" width="200" />
          <el-table-column label="项目名称" prop="b" />
          <el-table-column label="项目类别名称" prop="c" />
          <el-table-column label="工作时间(h)" prop="d" />
          <el-table-column label="工作费用(元)" prop="d" />
          <el-table-column label="备注" prop="d" width="100" />
          <el-table-column label="操作" width="140">
            <template #default>
              <el-button type="primary" size="mini" @click="repairDialog3 = true">编辑</el-button>
              <el-button type="danger" size="mini" @click="del">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>

    <!-- 弹出框：新增维修项目类别 -->
    <div v-dialogdrag>
      <el-dialog v-model="repairDialog" title="新增" width="30%" @close="repairDialogClose">
        <el-form label-width="100px" :model="repairForm" ref="repairFormRef" :rules="repairFormRules" size="small">
          <el-form-item label="项目类别编码" prop="a" style="width:100%">
            <el-input v-model="repairForm.a" placeholder="自动生成"></el-input>
          </el-form-item>
          <el-form-item label="项目类别名称" prop="b" style="width:100%">
            <el-input v-model="repairForm.b"></el-input>
          </el-form-item>
          <el-form-item label="备注" prop="d" style="width:100%">
            <el-input v-model="repairForm.d" type="textarea" :rows="1"></el-input>
          </el-form-item>
        </el-form>
        <template #footer>
          <span class="dialog-footer">
            <el-button type="primary" size="mini" @click="repairSureBtn">确定</el-button>
            <el-button type="info" size="mini" @click="repairDialog = false">取消</el-button>
          </span>
        </template>
      </el-dialog>
    </div>

    <!-- 弹出框：编辑维修项目类别 -->
    <div v-dialogdrag>
      <el-dialog v-model="repairDialog1" title="编辑" width="30%" @close="repairDialog1Close">
        <el-form label-width="100px" :model="repairForm1" ref="repairForm1Ref" :rules="repairForm1Rules" size="small">
          <el-form-item label="项目类别编码" prop="a" style="width:100%">
            <el-input v-model="repairForm.a" placeholder="自动生成"></el-input>
          </el-form-item>
          <el-form-item label="项目类别名称" prop="b" style="width:100%">
            <el-input v-model="repairForm.b"></el-input>
          </el-form-item>
          <el-form-item label="备注" prop="d" style="width:100%">
            <el-input v-model="repairForm.d" type="textarea" :rows="1"></el-input>
          </el-form-item>
        </el-form>
        <template #footer>
          <span class="dialog-footer">
            <el-button type="primary" size="mini" @click="repair1SureBtn">确定</el-button>
            <el-button type="info" size="mini" @click="repairDialog1 = false">取消</el-button>
          </span>
        </template>
      </el-dialog>
    </div>

    <!-- 弹出框：新增维修项目 -->
    <div v-dialogdrag>
      <el-dialog v-model="repairDialog2" title="新增" width="30%" @close="repairDialog2Close">
        <el-form label-width="100px" :model="repairForm2" ref="repairForm2Ref" :rules="repairForm2Rules" size="small">
          <el-form-item label="项目编码" prop="a" style="width:100%">
            <el-input v-model="repairForm2.a" placeholder="自动生成"></el-input>
          </el-form-item>
          <el-form-item label="项目类别名称" prop="b">
            <el-select v-model="repairForm2.b" placeholder="请选择" style="width:100%" filterable>
              <el-option label="选项" value="1"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="项目名称" prop="c" style="width:100%">
            <el-input v-model="repairForm2.a" placeholder="自动生成"></el-input>
          </el-form-item>
          <el-form-item label="工作时间(h)" prop="a" style="width:100%">
            <el-input v-model="repairForm2.a" placeholder="自动生成"></el-input>
          </el-form-item>
          <el-form-item label="工作费用(元)" prop="a" style="width:100%">
            <el-input v-model="repairForm2.a" placeholder="自动生成"></el-input>
          </el-form-item>
        </el-form>
        <template #footer>
          <span class="dialog-footer">
            <el-button type="primary" size="mini" @click="repairSure2Btn">确定</el-button>
            <el-button type="info" size="mini" @click="repairDialog2 = false">取消</el-button>
          </span>
        </template>
      </el-dialog>
    </div>

    <!-- 弹出框：编辑维修项目 -->
    <div v-dialogdrag>
      <el-dialog v-model="repairDialog3" title="编辑" width="30%" @close="repairDialog3Close">
        <el-form label-width="100px" :model="repairForm3" ref="repairForm3Ref" :rules="repairForm3Rules" size="small">
          <el-form-item label="项目编码" prop="a" style="width:100%">
            <el-input v-model="repairForm2.a" placeholder="自动生成"></el-input>
          </el-form-item>
          <el-form-item label="项目类别名称" prop="b">
            <el-select v-model="repairForm2.b" placeholder="请选择" style="width:100%" filterable>
              <el-option label="选项" value="1"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="项目名称" prop="c" style="width:100%">
            <el-input v-model="repairForm2.a" placeholder="自动生成"></el-input>
          </el-form-item>
          <el-form-item label="工作时间(h)" prop="a" style="width:100%">
            <el-input v-model="repairForm2.a" placeholder="自动生成"></el-input>
          </el-form-item>
          <el-form-item label="工作费用(元)" prop="a" style="width:100%">
            <el-input v-model="repairForm2.a" placeholder="自动生成"></el-input>
          </el-form-item>
        </el-form>
        <template #footer>
          <span class="dialog-footer">
            <el-button type="primary" size="mini" @click="repairSure3Btn">确定</el-button>
            <el-button type="info" size="mini" @click="repairDialog3 = false">取消</el-button>
          </span>
        </template>
      </el-dialog>
    </div>

  </div>
</template>

<script>
import Header from "@/components/Header";
import moment from "moment";
import LInput from "../../../components/LInput.vue";
import LDateTimeSelect2 from "../../../components/LDateTimeSelect2.vue";
import LButton from "../../../components/LButton.vue";
import LSelect from "@/components/LSelect.vue";
import Template from "@/views/OperaManage/Equipment/template.vue";

export default {
  components: {
    Header,
    LInput,
    LDateTimeSelect2,
    LButton,
    LSelect,
    Template,
  },
  data() {
    return {
      a: "",
      b: "",
      c: "",
      d: "",
      option1: [
        {
          value: "1",
          label: "选项1",
        },
        {
          value: "2",
          label: "选项2",
        },
      ],
      tableData: [
        {
          a: "wxlb10",
          b: "空调",
          c: "空调",
        },
      ],
      tableData1: [
        {
          a: "wxxm18072814122642",
          b: "通用工时",
          c: "设备维修",
          d: "1",
          e: "1",
        },
      ],
      //=============================================
      repairDialog: false,
      repairForm: {},
      repairDialog1: false,
      repairForm1: {},
      repairDialog2: false,
      repairForm2: {},
      repairDialog3: false,
      repairForm3: {},
      subTableData1: [
        {
          a: "主楼",
          b: "DDOO",
        },
        {
          a: "东辅楼",
          b: "DDO1",
        },
      ],
      subTable1Select: null,
      subTableData2: [],
    };
  },
  mounted() {},
  beforeUnmount() {},
  methods: {
    //获取搜索栏信息
    getNewSelect1(s) {
      this.c = s;
    },
    //清空搜索栏
    clearSelected() {
      this.a = "";
      this.c = "";
    },
    //清空form表单
    repairDialogClose() {
      this.$refs.repairFormRef.resetFields(); //新增仓库
    },
    repairDialog1Close() {
      this.$refs.repairForm1Ref.resetFields(); //编辑仓库
    },
    repairDialog2Close() {
      this.$refs.repairForm2Ref.resetFields(); //新增库区
    },
    repairDialog3Close() {
      this.$refs.repairForm3Ref.resetFields(); //编辑库区
    },
    //删除数据按钮
    del() {
      this.$confirm("此操作将永久删除该信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          // post("/airChannel/deleteAirChannel", { id: id }).then((res) => {
          //   // console.log(res);
          //   if (res.data.code == 200) {
          //     this.$message.success(res.data.data);
          //     this.getData();
          //   } else {
          //     this.$message.error(res.data.data);
          //   }
          // });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>


<style lang="less" scoped>
@import "../../OperaManage/opera.less";

.search_bar {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.row-1 {
  display: flex;
  justify-content: space-between;
  padding: 0 2vw 0 0;
}
</style>